package com.supms.course.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.supms.course.domain.TestReviewItems;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.supms.course.domain.CourseTargetItem;
import com.supms.course.service.ICourseTargetItemService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 课程目标达成度评价项Controller
 * 
 * @author LiangHao
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/CourseTargetItem")
public class CourseTargetItemController extends BaseController
{
    @Autowired
    private ICourseTargetItemService courseTargetItemService;

    /**
     * 查询课程目标达成度评价项列表
     */
    @RequiresPermissions("course:CourseTargetItem:list")
    @GetMapping("/list")
    public TableDataInfo list(CourseTargetItem courseTargetItem)
    {
        startPage();
        List<CourseTargetItem> list = courseTargetItemService.selectCourseTargetItemList(courseTargetItem);
        return getDataTable(list);
    }

    /**
     * 导出课程目标达成度评价项列表
     */
    @RequiresPermissions("course:CourseTargetItem:export")
    @Log(title = "课程目标达成度评价项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseTargetItem courseTargetItem)
    {
        List<CourseTargetItem> list = courseTargetItemService.selectCourseTargetItemList(courseTargetItem);
        ExcelUtil<CourseTargetItem> util = new ExcelUtil<CourseTargetItem>(CourseTargetItem.class);
        util.exportExcel(response, list, "课程目标达成度评价项数据");
    }

    /**
     * 获取课程目标达成度评价项详细信息
     */
    @RequiresPermissions("course:CourseTargetItem:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(courseTargetItemService.selectCourseTargetItemById(id));
    }

    /**
     * 新增课程目标达成度评价项
     */
    @RequiresPermissions("course:CourseTargetItem:add")
    @Log(title = "课程目标达成度评价项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseTargetItem courseTargetItem)
    {
        return toAjax(courseTargetItemService.insertCourseTargetItem(courseTargetItem));
    }

    /**
     * 修改课程目标达成度评价项
     */
    @RequiresPermissions("course:CourseTargetItem:edit")
    @Log(title = "课程目标达成度评价项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseTargetItem courseTargetItem)
    {
        return toAjax(courseTargetItemService.updateCourseTargetItem(courseTargetItem));
    }

    /**
     * 删除课程目标达成度评价项
     */
    @RequiresPermissions("course:CourseTargetItem:remove")
    @Log(title = "课程目标达成度评价项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(courseTargetItemService.deleteCourseTargetItemByIds(ids));
    }

    /**
     * 添加本科课程目标达成度评价（添加中间表）
     */
    @PostMapping("/addCourseTargetEval")
    public AjaxResult addCourseTargetEval(@RequestBody List<CourseTargetItem> courseTargetItemList) {
        return toAjax(courseTargetItemService.addCourseTargetEval(courseTargetItemList));
    }
}
